package com.smartleanx.module.hrm.controller.admin.companysystememployee;

import com.smartleanx.framework.common.pojo.CommonResult;
import com.smartleanx.framework.security.core.annotations.PreAuthenticated;
import com.smartleanx.module.hrm.context.EmployeeContextHolder;
import com.smartleanx.module.hrm.controller.admin.companysystememployee.vo.CompanySystemEmployeeSaveReqVO;
import com.smartleanx.module.hrm.service.companysystememployee.CompanySystemEmployeeService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.validation.Valid;

import static com.smartleanx.framework.common.pojo.CommonResult.success;

@Tag(name = "员工PC端 - 公司制度已学习")
@RestController
@RequestMapping("/hrm/pc-company-system-employee")
@Validated
public class PCCompanySystemEmployeeController {

    @Resource
    private CompanySystemEmployeeService companySystemEmployeeService;

    @PostMapping("/create")
    @Operation(summary = "员工端确认已学习公司制度")
    @PreAuthenticated
    public CommonResult<Long> createCompanySystemEmployee(@Valid @RequestBody CompanySystemEmployeeSaveReqVO createReqVO) {
        createReqVO.setEmployeeId(EmployeeContextHolder.getEmployeeId());
        return success(companySystemEmployeeService.createCompanySystemEmployee(createReqVO));
    }
}
